package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DzbqSysteminfo;
import com.ruoyi.system.service.IDzbqSysteminfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 设备系统Controller
 * 
 * @author tianxingxia
 * @date 2025-01-31
 */
@RestController
@RequestMapping("/system/systeminfo")
public class DzbqSysteminfoController extends BaseController
{
    @Autowired
    private IDzbqSysteminfoService dzbqSysteminfoService;

    /**
     * 查询设备系统列表
     */
    @PreAuthorize("@ss.hasPermi('system:systeminfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(DzbqSysteminfo dzbqSysteminfo)
    {
        startPage();
        List<DzbqSysteminfo> list = dzbqSysteminfoService.selectDzbqSysteminfoList(dzbqSysteminfo);
        return getDataTable(list);
    }

    /**
     * 导出设备系统列表
     */
    @PreAuthorize("@ss.hasPermi('system:systeminfo:export')")
    @Log(title = "设备系统", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DzbqSysteminfo dzbqSysteminfo)
    {
        List<DzbqSysteminfo> list = dzbqSysteminfoService.selectDzbqSysteminfoList(dzbqSysteminfo);
        ExcelUtil<DzbqSysteminfo> util = new ExcelUtil<DzbqSysteminfo>(DzbqSysteminfo.class);
        util.exportExcel(response, list, "设备系统数据");
    }

    /**
     * 获取设备系统详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:systeminfo:query')")
    @GetMapping(value = "/{systemId}")
    public AjaxResult getInfo(@PathVariable("systemId") Integer systemId)
    {
        return success(dzbqSysteminfoService.selectDzbqSysteminfoBySystemId(systemId));
    }

    /**
     * 新增设备系统
     */
    @PreAuthorize("@ss.hasPermi('system:systeminfo:add')")
    @Log(title = "设备系统", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DzbqSysteminfo dzbqSysteminfo)
    {
        return toAjax(dzbqSysteminfoService.insertDzbqSysteminfo(dzbqSysteminfo));
    }

    /**
     * 修改设备系统
     */
    @PreAuthorize("@ss.hasPermi('system:systeminfo:edit')")
    @Log(title = "设备系统", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DzbqSysteminfo dzbqSysteminfo)
    {
        return toAjax(dzbqSysteminfoService.updateDzbqSysteminfo(dzbqSysteminfo));
    }

    /**
     * 删除设备系统
     */
    @PreAuthorize("@ss.hasPermi('system:systeminfo:remove')")
    @Log(title = "设备系统", businessType = BusinessType.DELETE)
	@DeleteMapping("/{systemIds}")
    public AjaxResult remove(@PathVariable Integer[] systemIds)
    {
        return toAjax(dzbqSysteminfoService.deleteDzbqSysteminfoBySystemIds(systemIds));
    }
}
